<%@ page import="gdepot.User" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main">
    <g:set var="entityName" value="${message(code: 'user.label', default: 'User')}"/>
    <title><g:message code="default.show.label" args="[entityName]"/></title>
</head>

<body>

<div class="row">
    <div class="container">
        <ol class="breadcrumb">

            <li><g:link controller="user" action="index">User</g:link></li>
            <li>${userInstance.username}</li>
        </ol>
    </div>
</div>

<g:if test="${flash.message}">
    <div class="alert alert-warning">
        <a href="#" class="close" data-dismiss="alert">
        &times;
        </a>
        <strong>${flash.message}</strong>
    </div>
</g:if>

<sec:ifAllGranted  roles="ROLE_SYSTEM_MANAGER">
    <div class="row" style="padding-bottom:10px">
        <div class="container">
            <div class="col-sm-9"></div>
            <div class="col-sm-3" align="right" style="padding:0px">
                <ul class="list-inline">
                    <li>
                        <g:form url="[resource:userInstance, action:'delete']" method="DELETE">
                            <g:actionSubmit class="btn btn-default btn-sm" action="delete" value="删除"/>
                        </g:form>
                    </li>
                    <li><g:link action="edit" resource="${userInstance}" class="btn btn-default btn-sm">编辑</g:link></li>
                    <li><g:link action="create" class="btn btn-default btn-sm">新建</g:link></li>
                </ul>
            </div>
        </div>
    </div>
</sec:ifAllGranted>

<div class="row">
    <div class="container">

        <table class="table table-bordered table-hover">
            <tr>
                <td width="30%">用户名</td>
                <td width="70%">    <g:if test="${userInstance.username}"><g:fieldValue bean="${userInstance}" field="username"/></g:if></td>
            </tr>
            <tr>
                <td width="30%">姓名</td>
                <td width="70%"> <g:if test="${userInstance.fullName}"><g:fieldValue bean="${userInstance}" field="fullName"/></g:if></td>
            </tr>
            <tr>
                <td width="30%">性別</td>
                <td width="70%"> <g:if test="${userInstance.gender}"><g:fieldValue bean="${userInstance}" field="gender"/></g:if></td>
            </tr>
            <tr>
                <td width="30%">邮箱</td>
                <td width="70%"> <g:if test="${userInstance.email}"><g:fieldValue bean="${userInstance}" field="email"/></g:if></td>
            </tr>
            <tr>
                <td width="30%">电话</td>
                <td width="70%"> <g:if test="${userInstance.phone}"><g:fieldValue bean="${userInstance}" field="phone"/></g:if></td>
            </tr>

            <tr>
                <td width="30%">是否有效</td>
                <td width="70%"><g:if test="${userInstance.enabled}"><g:formatBoolean boolean="${userInstance?.enabled}" /></g:if></td>
            </tr>
            <tr>
                <td width="30%">帐户过期</td>
                <td width="70%"><g:if test="${userInstance.accountExpired}"><g:formatBoolean boolean="${userInstance?.accountExpired}" /></g:if></td>
            </tr>
            <tr>
                <td width="30%">帐户锁定</td>
                <td width="70%"><g:if test="${userInstance.accountExpired}"><g:formatBoolean boolean="${userInstance?.accountLocked}" /></g:if></td>
            </tr>
            <tr>
                <td width="30%">口令过期</td>
                <td width="70%"><g:if test="${userInstance.passwordExpired}"><g:formatBoolean boolean="${userInstance?.passwordExpired}" /></g:if></td>
            </tr>
            <tr>
                <td width="30%">创建时间</td>
                <td width="70%"><g:if test="${userInstance.createdDate}"><g:formatDate date="${userInstance?.createdDate}" /></g:if></td>
            </tr>
            <tr>
                <td width="30%">修改时间</td>
                <td width="70%"><g:if test="${userInstance.modifiedDate}"><g:formatDate date="${userInstance?.modifiedDate}" /></g:if></td>
            </tr>
        </table>

    </div>
</div>
<sec:ifAllGranted  roles="ROLE_SYSTEM_MANAGER">

    <div class="row">
        <div class="container">
            <div class="panel panel-default">
                <div class="panel-heading" style="padding:5px">
                    <table width="100%">
                        <tr>
                            <td width="20%" style="padding-left:10px">角色</td>
                            <td width="75%"></td>
                            <td width="5%">
                                <g:link controller="userRole" action="create" params="['user.id': userInstance?.id]" class="btn btn-default btn-sm btn-block">增加授权</g:link>
                            </td>
                        </tr>
                    </table>
                </div>
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <td width="20%">角色</td>
                        <td width="20%"></td>
                        <td width="20%"></td>
                        <td width="20%"></td>
                        <td width="15%"></td>
                        <td width="5%"></td>
                    </tr>
                    </thead>
                    <tbody>
                    <g:each in="${userInstance?.roles?}" var="r">
                        <tr>
                            <td width="20%">${r?.encodeAsHTML()}</td>
                            <td width="20%"></td>
                            <td width="20%"></td>
                            <td width="20%"></td>
                            <td width="15%"></td>
                            <td width="5%">
                                <g:link action="deleteRole" params="[userId: r.user.id, roleId: r.role.id]" class="btn btn-danger btn-block btn-xs btn-block">取消授权</g:link>
                            </td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</sec:ifAllGranted>


</body>
</html>
